package com.ge.boot06core.service;

import com.ge.boot06core.entity.UserEntity;
import com.ge.boot06core.event.LoginSuccessEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;

/**
 * 测试基于事件驱动开发<br>
 * 系统服务
 */

@Service
public class SysService {

    public void recordLog(String userName) {

        System.out.println(userName + " 登录信息已被记录");

    }

    @EventListener
    public void onEvent(LoginSuccessEvent event){

        System.out.println("SysService 接收到事件");
        UserEntity source = (UserEntity) event.getSource();
        recordLog(source.getUserName());

    }

}
